home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / VideoToolbox 96.06.15 / VideoToolboxSources / SetFileInfo.c < prev    next >
Text File  |  1995-07-26  |  2KB  |  87 lines

  1. /*
  2. SetFileInfo.c
  3.  
  4. USAGE
  5.  
  6.     SetFileInfo("Output File",'xxxx','yyyy');
  7.  
  8. ARGUMENTS
  9.  
  10.     char    *fileName;        The name of the file (including HFS
  11.                             directory name) to be set.
  12.     
  13.     OStype    'xxxx'            The four character file type, eg 'TEXT'
  14.  
  15.     OStype    'xxxx'            The four character creator, eg 'XCEL','CGRF','QKPT','QED1'
  16.  
  17. COMMENTS
  18.  
  19.     The syntax 'xxxx' results in four characters packed into a short int. This is
  20.     a Macintosh convention, not Standard C. That's ok since this routine is strictly
  21.     Macintosh anyway.
  22.  
  23. EXAMPLE
  24.  
  25.     ** create Cricket data file **
  26.     myFile=fopen("LuminanceCalibration.data","w");
  27.     SetFileInfo("LuminanceCalibration.data",'TEXT','CGRF');
  28.     fprintf(myFile,"*\n");
  29.     fprintf(myFile,"x\ty\n");
  30.     for(i=0;i<n;i++)fprintf(myFile,"%9g\t%9g\n",x[i],y[i]);
  31.     fclose(myFile);
  32.  
  33.     
  34. HISTORY
  35. 12/87    EJC wrote q_make_crick()
  36. 8/89    dgp Renamed and rewritten.
  37. 8/24/91    dgp    Made compatible with THINK C 5.0.
  38. 12/28/92 dgp Removed obsolete support for THINK C 4.
  39.  
  40. *****************************************************************************/
  41. #include "VideoToolbox.h"    /* for prototype of itself */
  42. //#include <Files.h>
  43.  
  44. void SetFileInfo(char *fileName,OSType fileType,OSType fileCreator)
  45. {
  46.     FInfo outFileInfo;
  47.     
  48.     c2pstr(fileName);
  49.     GetFInfo((StringPtr)fileName,0,&outFileInfo);
  50.     outFileInfo.fdType = fileType;
  51.     outFileInfo.fdCreator = fileCreator;
  52.     SetFInfo((StringPtr)fileName,0,&outFileInfo);
  53.     p2cstr((void *)fileName);
  54. }
  55.  
  56. /*
  57. Changing the ioDrMdDat field of your file's parent directory forces the
  58. Finder into updating its window. This is useful after you've changed a file's
  59. type, to get the Finder to immediately show the new icon.
  60.  
  61. HISTORY:
  62. Craig Marciniak, TemplarDev@aol.com, published in March, 1995 issue of MacTech Magazine, p. 80.
  63. */
  64. #if UNIVERSAL_HEADERS
  65.     #include <LowMem.h>
  66. #else
  67.     extern pascal long LMGetTime(void)={0x2EB8, 0x020C}; /* MOVE.L $020C,(SP) */
  68. #endif
  69. void ForceFinderToUpdateFileIcon(FSSpecPtr file);
  70.  
  71. void ForceFinderToUpdateFileIcon(FSSpecPtr file)
  72. {
  73.     CInfoPBRec tempPB;
  74.  
  75.     if(file != 0L){
  76.         tempPB.dirInfo.ioNamePtr=0L;
  77.         tempPB.dirInfo.ioVRefNum=file->vRefNum;
  78.         tempPB.dirInfo.ioFDirIndex=-1;
  79.         tempPB.dirInfo.ioDrDirID=file->parID;
  80.         if(PBGetCatInfoSync(&tempPB)==noErr){
  81.             tempPB.dirInfo.ioDrMdDat=LMGetTime();
  82.             tempPB.dirInfo.ioDrDirID=file->parID;
  83.             PBSetCatInfoSync(&tempPB);
  84.         }
  85.     }
  86. }
  87.